package com.lzy.mall.member.controller;


import com.lzy.mall.common.utils.PageUtils;
import com.lzy.mall.common.utils.ResultUtils;
import com.lzy.mall.member.entity.UmsMember;
import com.lzy.mall.member.feign.CouponController;
import com.lzy.mall.member.service.UmsMemberService;
import com.lzy.mall.member.vo.login.UserLoginVo;
import com.lzy.mall.member.vo.login.UserRegisterVo;
import org.springframework.web.bind.annotation.*;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

/**
 * 会员(UmsMember)表控制层
 *
 * @author lzy
 * @since 2021-08-25 11:38:46
 */
@RestController
@RequestMapping("member")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class UmsMemberController {

    private final CouponController couponController;

    private final UmsMemberService memberService;

    @GetMapping("/coupon")
    public ResultUtils coupon(){
        return couponController.memberCoupon().put("msg","member模块远程调用coupon模块");
    }
    //member/list
    @GetMapping("/list")
    public ResultUtils list(@RequestParam Map<String, Object> params){
        PageUtils page =  memberService.queryPage(params);
        return ResultUtils.ok().put("page", page);
    }

    @PostMapping("/register")
    public ResultUtils register(@RequestBody UserRegisterVo userRegisterVo){
        return memberService.register(userRegisterVo);
    }

    @PostMapping("/login")
    public ResultUtils login(@RequestBody UserLoginVo vo){
        return memberService.login(vo);
    }
}
